from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time

dr = webdriver.Chrome(service=Service('chromedriver.exe'))
dr.maximize_window()
dr.get('https://bahuyun.com/bdp/form/1370889698236956672')

dr.implicitly_wait(10)
for i in range(2):
    # 单选框
    dr.find_element(By.XPATH, '//*[@id="my-node"]/div[1]/div/div[2]/div/div/div[2]/div/i').click()
    # 多选框
    dr.find_element(By.XPATH, '//*[@id="my-node"]/div[2]/div/div[2]/div/div/div[1]/div/i').click()
    dr.find_element(By.XPATH, '//*[@id="my-node"]/div[2]/div/div[2]/div/div/div[3]/div/i').click()
    # 下拉菜单
    dr.find_element(By.XPATH, '//*[@id="my-node"]/div[3]/div/div[2]/div/div/div/select/option[1]').click()
    # 填写日期
    dr.find_element(By.XPATH, '//*[@id="input-YvRQ32wsVyUFlGRoRBio7"]').send_keys('0020220101')
    # 评价
    dr.find_element(By.XPATH, '//*[@id="my-node"]/div[5]/div/div[2]/div/div[1]/div[2]/div[4]/i').click()
    dr.find_element(By.XPATH, '//*[@id="my-node"]/div[5]/div/div[2]/div/div[2]/div[2]/div[5]').click()
    # 上传附件，上传图片的路径必须是绝对路径
    dr.find_element(By.XPATH, '//*[@id="my-node"]/div[6]/div/div[2]/div/div/div/div/div/input').send_keys(
        'C:\\Users\\Administrator\\Desktop\\报告\\图片\\1.jpg')
    # 提交
    dr.find_element(By.XPATH, '//*[@id="submit-button"]').click()
    # 在填写一次
    dr.find_element(By.XPATH, '//*[@id="app"]/div/div/div[1]/div[2]/div[3]/button').click()
    # 获取全部标签页的句柄
    handles = dr.window_handles
    print(handles)
    time.sleep(2)
    # 关闭之前控制的标签页
    dr.close()
    # 通过句柄切换标签页
    time.sleep(2)
    dr.switch_to.window(handles[1])
    # 获取当前标签页句柄
    dr2 = dr.current_window_handle
    print(dr2)
time.sleep(23)






